(function($){
	$.widget('yi.accordination',{
		options:{
			id:'',
			containerId:'',
			collapsed:true,
			title:''
		},
		_create: function(){
			var self = this;
			//current div id
			var id = options.id;
			var options = self.options;
			//the div will be expand / collapsed
		    var container = $("#" + options.containerId);
		    var bodyId = "accordionBody_" + id;
		    var bodyContainerId = "accordionBodyContainer_" + id;
		    var toogleIconId = "toogleIcon_" + id;
		    var collapsed = options && options.collapsed;
		    var header;
		    var body;
			
			
			var html = '<div class="well-small accordiion-header">';
			html += '<i id=toogleIcon_"';
			html += id;
			html += '" data-toggle="collapse" data-target="#';
			html += 'accordionBody_' + id;
			html += '" class="icon-white ';
			html += (collapsed ? 'icon-plus' : 'icon-minus') + '"/>';
			if(options && options.infoIcon){
				html += ' <i class="icon-info-sign" data-original-title="' + options.infoIcon.title + '" data-content="' + options.infoIcon.body + ' "></i>';
			}
			html += '</div>';
			header = $(html);
			if (options.actions) {
	            $.each(options.actions, function (index, action) {
	                var iconButton;
	                switch (action.actionType) {
	                    case actionType.Edit:
	                        iconButton = $('<i class="icon-edit pull-right icon-white"></i>');
	                        break;
	                }
	                iconButton.click(action.callback);
	                header.append(iconButton);
	            });
	        }
			
		}
		container.append(header);
        container.append('<div id="' + bodyContainerId + '" class="collapse ' + (collapsed ? "" : "in") + '"><div id="' + bodyId + '" class="well-small"></div></div>');
        body = $("#" + bodyId);

        $("#" + toogleIconId).click(function () {
            collapsed = !collapsed;
            $(this).toggleClass("icon-minus").toggleClass("icon-plus");
        });
		
		
	});
})(jQuery);